import apiClient from '@/api/apiClient.ts';
import { OSSDataType } from '#/entity.ts';

export enum FileServicesApi {
  GetOssFileToken = '/roadCure/file/getOssFileToken',
  AddFile = '/roadCure/file/addFile',
}

export interface FileInfo {
  id?: string;
  fileName: string;
  fileSize: number;
  fileType: string;
  fileUrl: string;
}

export type AddFileParams = FileInfo[];

interface AddFileResponse extends FileInfo {
  id: string;
}

const getOssToken = () => apiClient.get<OSSDataType>({ url: FileServicesApi.GetOssFileToken });

const addFile = (data: AddFileParams) =>
  apiClient.post<AddFileResponse[]>({ url: FileServicesApi.AddFile, data });

export default {
  getOssToken,
  addFile,
};
